<?php

/**
 * Salarie filter form.
 *
 * @package    sopN
 * @subpackage filter
 * @author     Your name here
 * @version    SVN: $Id: sfPropelFormFilterTemplate.php 11675 2008-09-19 15:21:38Z fabien $
 */
class SalarieFormFilter extends BaseSalarieFormFilter
{
  public function configure()
  {
    // On récupère les utilisateurs de l'application
    $c = new Criteria();
    $c->addAscendingOrderByColumn(sfGuardUserPeer::USERNAME);
    $this->users = sfGuardUserPeer::doSelect($c);
    
    $tabUsers = array('' => '');
    foreach ($this->users as $user)
        $tabUsers[$user->getId()] = $user->getUsername();
      
    // Modification du widget 'guard_id'
    $this->widgetSchema['guard_id'] = new sfWidgetFormSelect(array(
        'choices' => $tabUsers,
        'label'   => 'Utilisateur associé'
    ));
    
    $this->validatorSchema['guard_id'] = new sfValidatorChoice(array(
        'choices' => array_keys($tabUsers),
        'required' => false
    ));
      
    // Modification du widget 'actif'
    $this->widgetSchema['actif'] = new sfWidgetFormChoice(array('choices' =>
    array('1' => 'Oui', '0' => 'Non')));

    $this->validatorSchema['actif'] = new sfValidatorChoice(array('choices' =>
    array_keys(array('1' => 'Oui', '0' => 'Non'))));
    
    $this->widgetSchema['asso_salarie_unite_fonctionnelle_list']->addOption('renderer_class', 'sfWidgetFormSelectDoubleListSop')
                                                                ->addOption('renderer_options', array(
                                                                    'associated_first'    => false, 
                                                                    'label_unassociated'  => "Non associ&eacute;", 
                                                                    'label_associated'    => "Associ&eacute;"
                                                                ))
                                                                ->addOption('label', "Unités associés")
                                                                ->setAttribute('size', 5);
    $this->validatorSchema['asso_salarie_unite_fonctionnelle_list'] = new sfValidatorPass(array('required' => false));
  }

  public function getFields()
  {
    $fields = parent::getFields();
    $fields['guard_id'] = 'ForeignKey';
    $fields['actif']    = 'Boolean';
    
    return $fields;
  }
}
